"""
    捕获异常使用：
        try:
        except:
    异常是有类型的，可以捕获所有异常也可以捕获规定异常
"""
# 捕获所有异常
try:
    print(name)
except:
    print('变量未定义')

# 捕获规定异常
try:
    1 / 0
except ZeroDivisionError as e:
    print('异常了类型是：', e)

# 捕获多个规定异常
try:
    # print(name)
    1 / 0
except (ZeroDivisionError, NameError) as e:
    print('异常了类型是：', e)

# 捕获所有异常
try:
    f = open('./1234.txt', 'r', encoding="UTF-8")
except Exception as e:
    print('定义捕获异常', e)

# 捕获异常的 else 和 finally
try:
    # print(name)
    print('name')
except:
    print('异常了。')
else:
    print('没异常，牛逼')
finally:
    print('有没有异常都他妈走')
